Color image data in a computer includes many components. Each pixel of an image is generally described by components for the color of the pixel (e.g., red, green, and blue), intensity and other information including relative position with respect to other pixels in the image. Each pixel is therefore represented by multiple pieces of information. These multiple pieces of information are often stored in a pixel-interleaved format, data bits of components of each pixel being arranged relative to one another to form a pixel data cluster. All pixel data clusters of the image are arranged relative to one another in a sequence. For example, data for a color image can be in the form of R1G1B1R2G2B2 . . . , where R, G, and B often represent the data channels of red, green, and blue color intensity, respectively, and indexes 1 and 2 indicate pixels 1 and 2. In general, the data for each channel can also include digital information other than color information. For example, the .alpha.-channel includes the information for image composting.
Even though the data is usually stored in this pixel interleaved format, data about one channel (or band) of an image is sometimes extracted and used alone for processing or printing. For example, the data about the red component of an image may be separated from other data of the image and be processed to achieve a desired result such as color touch-up. It may be also desirable to separate data of all the channels from a pixel-interleaved format so that each channel can be independently processed.
Channel extraction is sometimes done using software. For example, the red (R) channel may be extracted from a 3-channel (RGB) 8-bit type image in the following way as expressed in the C programing language:
______________________________________ void ImageChannelExtractRed.sub.-- U8.sub.-- 1() unsigned char *sp; /* pointer to input data */ unsigned char *dp; /* pointer to output data */ unsigned char dd; /* 8-bit image data */ int dsize; /* image data size in pixels */ int i; for (i=0; i&lt;dsize; i++) { dd =*sp; /* read an 8-bit data */ *dp=dd; /* write an 8-bit data */ sp =sp + 3; /* sp points to next red element */ dp =dp + 1; /* dp points to next red element */ } } ______________________________________
Extraction of each byte of the red data requires two instructions: one load instruction (read) and one store instruction (write). Instructions for pointer increment may also be needed but can be grouped with (executed simultaneously with) load or store instructions. Thus, channel bytes can be extracted at a rate of 2 execution cycles per byte.
Another prior-art method of channel extraction uses data aligning instructions in the Visual Instruction Set (VIS) for UltraSPARC systems from Sun Microsystems. VIS is a comprehensive set of single-cycle instructions for processing audio, video, and imaging information in UltraSPARC microprocessors. A description of VIS can be found in, for example, "VIS User's Manual", release 1.0, Sun Microsystems, April, 1996, which is incorporated by reference. One example of this method with VIS is extracting the red (R) channel from a 3-channel (RGB) 8-bit type image by the following process in the C language:
______________________________________ void ImageChannelExtractRed.sub.-- U8.sub.-- 2() unsigned char *sp; /* pointer to input data */ vis.sub.-- d64 *dp; /* pointer to output data */ vis.sub.-- d64 sd; /* 64-bit intermediate value */ vis.sub.-- d64 dd; /* 64-bit output data */ int dsize; /* image data size in pixels */ int i; vis.sub.-- alignaddr((void *) 0, 7); for (i = 0; i &lt; dsize/8; i++){ sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 21); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 18); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 15); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 12); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 9); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 6); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 3); dd = vis.sub.-- faligndata(sd, dd); sd = vis.sub.-- ld.sub.-- u8.sub.-- i(sp, 0); dd = vis.sub.-- faligndata(sd, dd); sp += 24; *dp++ = dd; } } ______________________________________
This allows eight 8-bit red elements to be extracted in an iteration.
However, the above channel extraction includes at least eight load instructions (i.e., vis.sub.-- ld.sub.-- u8.sub.-- i) and one store instruction. Eight VIS instructions FALIGNDATAs are used for shifting the 8-byte data into a 64-bit register. These can be grouped with load or store instructions. Therefore, the best performance for this technique is 1.125 cycles/byte (8 cycles load and 1 cycle store per 8 bytes).